#!/bin/bash
#SBATCH --job-name=Admix
#SBATCH --account=gem
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=8
#SBATCH --mem=32gb
#SBATCH --time=24:00:00

genotype_file=$1

##Run ADMIXTURE: Simulate best number of clusters (populations) in ccRCC dataset

for K in 1 2 3 4 5
	do ./admixture --cv ./${genotype_file}.bed $K | tee log${K}.out >> CV_error_merged.txt
done

#grep CV errors for K values only
grep -h CV log*.out >> CV_error1_merged.txt


##Run PCA
plink --bed ./${genotype_file} --pca --out PCA_${genotype_file}